import { createStore, applyMiddleware } from 'redux'
import logger from 'redux-logger';
import thunk from 'redux-thunk';
import { ALLSTATE, ALLACTION, LISTITEM } from '../types/store.d'
const initialState = {
    list: [],
    name: ""
}

const reducer = (state: ALLSTATE = initialState, action: ALLACTION) => {
    switch (action.type) {
        case "setList":
            state.list = action.data
            return { ...state }
        case "dsd":
            ((state.name) as string) = action.data
            return { ...state }
        default:
            return state
    }
}

const store = createStore(reducer, applyMiddleware(logger, thunk))

export default store